package com.dingreading.cloud.common.util;

import org.apache.commons.lang3.StringUtils;

public class PageUtil {
    /**
     * 当前页
     */
    private Integer page;
    /**
     * 页条数
     */
    private Integer rows;
    /**
     * 排序字段
     */
    private String sort;
    /**
     * 升序或降序
     */
    private boolean order;

    /**
     * 多条件排序
     */
//    private Sort sortOrder;
    public Integer getPage() {
        if (page == null || page <= 0) {
            page = 1;
        }
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public Integer getRows() {
        if (rows == null || rows <= 0) {
            rows = 10;
        }
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public String getSort() {
        if (StringUtils.isEmpty(sort) || StringUtils.isBlank(sort)) {
            sort = "id";
        }
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public boolean isOrder() {
        return order;
    }

    public void setOrder(boolean order) {
        this.order = order;
    }

//    public Sort getSortOrder() {
//        return sortOrder;
//    }

//    public void setSortOrder(Sort sortOrder) {
//        this.sortOrder = sortOrder;
//    }

    public Integer getPageValue() {
        return page;
    }
}